﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

namespace FBKPI.Tools.ImportExcel.Handler
{
    /// <summary>
    /// Summary description for DownloadTemplateHandler
    /// </summary>
    public class DownloadTemplateHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Write(Process(context));
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

        private string Process(HttpContext context)
        {
            string returnVal = string.Empty;

            string modul = context.Request.QueryString["modul"].ToString();

            if (modul != string.Empty)
            {
                switch (modul)
                {
                    case "employee":
                        returnVal = ConfigurationManager.AppSettings["EmployeeExcelTemplate"];
                        break;
                    case "kpi":
                        returnVal = ConfigurationManager.AppSettings["KPIExcelTemplate"];
                        break;
                    default:
                        break;
                }
            }

            return returnVal;
        }
    }
}